package gui.popupmenu;

import gui.image.ImageList;
import gui.image.ImagePanel;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Quân
 */
public class DeleteFromAlbumMouseAdaptor extends MouseAdapter {

    private ImageList imageList;
    private ImagePanel imagePanel;

    public DeleteFromAlbumMouseAdaptor(ImageList imageList) {
        this.imageList = imageList;
    }

    DeleteFromAlbumMouseAdaptor(ImagePanel imagePanel, ImageList imageList) {
        this.imageList = imageList;
        this.imagePanel = imagePanel;
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        try {
            imageList.removeImage(this.imagePanel);
            imageList.updateUI();
        } catch (IOException ex) {
            Logger.getLogger(DeleteFromAlbumMouseAdaptor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
